﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Wedn.Net.Utility
{
    /// <summary>
    /// Gravatar助手类
    /// </summary>
    public static class GravatarHelper
    {
        /// <summary>
        /// 获取Gravatar头像地址
        /// </summary>
        /// <param name="email">邮箱地址</param>
        /// <param name="def">缺省头像地址</param>
        /// <param name="size">大小</param>
        /// <param name="rank">等级</param>
        /// <returns>Gravatar头像地址</returns>
        public static string GetGravatar(string email, string def, int size, char rank)
        {
            return string.Format("http://0.gravatar.com/avatar/{0}?s={1}&d={2}&r={3}",
                StringHelper.GravatarMD5(email),
                size,
                string.IsNullOrEmpty(def) ? "http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D" + size : def,
                rank);
        }
    }
}
